<?php
  set_time_limit(0);
  function generaterandomfloat($minValue,$maxValue,$decimal){
    $intPowerTen = pow(10, $decimal);
    return mt_rand($minValue * $intPowerTen, $maxValue * $intPowerTen) / $intPowerTen;
  }
  mysql_connect('127.0.0.1', 'canarduser', 'canarduser');
  mysql_set_charset('utf8');
  mysql_select_db('cnrmandrake');
  for($invoices = 1; $invoices <= 10000; $invoices++) {
    $day = rand(1, 28);
    $month = rand(1, 12);
    $year = rand(1990, 2010);
    $date = sprintf("%s-%02s-%02s", (string) $year, (string) $month, (string) $day);
    $number = (string) rand(1000, 1999);
    $customer = rand(2, 9);
    $supplier = rand(1, 29);
    $concept = rand(1, 8);
    $vat21 = generaterandomfloat(1000, 40000, 2);
    $vat27 = generaterandomfloat(300, 30000, 2);
    $vat105 = generaterandomfloat(0, 150000, 2);
    $taxfree = generaterandomfloat(300, 50000, 2);
    $internaltax = generaterandomfloat(10, 900, 2);
    $query = sprintf("insert into invoices values (null, '%s', '%s', %d, %d, %d, %.2f, %.2f, %.2f, %.2f, %.2f, '', true)", $date, $number, $customer, $supplier, $concept, $vat21, $vat27, $vat105, $taxfree, $internaltax);
    mysql_query($query);
  }
  mysql_close();
?>
